package com.flying;

import javax.xml.transform.Source;

/**
 * @author 刘鹏飞
 * @Classname ArrayDem01
 * @Date 2024/12/16 17:55
 * @Created by 刘鹏飞
 * @Description 数组的声明和初始化
 */
public class ArrayDem01 {
    public static void main(String[] args) {

        // 数组是将固定长度的兼容类型的数据按照顺序存入到容器中
        // 数组的声明
        int[] s;
        // 动态初始化
        s=new int[10];

        for (int i = 0; i < s.length; i++) {
            s[i]=i*2+1;
        }

        for (int i = 0; i < s.length; i++) {
            System.out.println(s[i]);
        }


        Man[] men = new Man[10];
        Man man1 = new Man(1, 34);
        Man man2 = new Man(2, 19);
        Man man3 = new Man(3, 67);

        // 动态初始化
        men[0]=man1;
        men[1]=man2;
        men[2]=man3;

        System.out.println(men[0].getAge());
        System.out.println(men[0].getId());


    }

}



class Man{
    private int id;
    private int age;


    public Man(int id, int age) {
        this.id = id;
        this.age = age;
    }

    public Man() {
    }


    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Man{" +
               "id=" + id +
               ", age=" + age +
               '}';
    }
}